package com.seanchenxi.gwt.xmlrpc.client.impl;

import com.seanchenxi.gwt.xmlrpc.client.XmlRpcRequest;

/**
 * The Class XmlRpcRequestImpl.
 *
 * @param <T> the generic type
 */
public class XmlRpcRequestImpl<T> implements XmlRpcRequest<T>{
	
	/** The method name. */
	private String methodName;
	
	/** The params. */
	private Object params[];
	
	/**
	 * Instantiates a new xml rpc request impl.
	 *
	 * @param methodName the method name
	 * @param params the params
	 */
	public XmlRpcRequestImpl(String methodName, Object... params){
		this.methodName = methodName;
		this.params = params;
	}
	
	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcRequest#getMethodName()
	 */
	@Override
	public String getMethodName() {
		return methodName;
	}

	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcRequest#getParameterCount()
	 */
	@Override
	public int getParameterCount() {
		if(params != null) return params.length;
		return 0;
	}

	/* (non-Javadoc)
	 * @see com.seanchenxi.gwt.xmlrpc.client.XmlRpcRequest#getParameter(int)
	 */
	@Override
	public Object getParameter(int index) {
		if(params != null && index < getParameterCount()){
			return params[index];
		}
		return null;
	}
}
